package com.china08.yxyapi.api.manage.stu.mystudy.mistakes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;

/**
 * 错题本--学生端--vip,错题重做时,先验证是否vip
 * 
 * @author Richard.Wang
 *
 */
@CrossOrigin
@RestController
public class StuMistakesQuesVipSchController extends YxyApiBaseController {

    // @Autowired
    // StuVipValidateServiceImpl stuVipValidateServiceImpl;

    @RequestMapping(value = "/api_yw/manage/stu/mystudy/mistakes/vip/sch", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel process(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel model) {

        // // 获取学生id, 如果没有传递此参数,使用当前登录人id
        // String stuId = StringUtils.isNotBlank(model.stuId) ? model.stuId :
        // getProfile(request, response).getId();

        // String schoolId = getProfile(request, response).getSchoolId();

        RespModel respModel = new RespModel();
        String vipString = getProfile(request, response).getUserVip();
        Boolean userVip;
        if (vipString.equals("true")) {
            userVip = true;
        } else {
            userVip = false;
        }
        // respModel.vip = stuVipValidateServiceImpl.stuVipMistakes(stuId,
        // schoolId);
        respModel.vip = userVip;
        return respModel;
    }

    /* 请求参数 */
    protected static class ReqModel extends YxyApiReqModel {
        public String stuId;
    }

    /* 响应参数 */
    protected static class RespModel extends YxyApiRespModel {
        public Boolean vip;// 是否为vip
    }
}
